package clock.socoolby.com.clock.widget.animatorview.animator;


import clock.socoolby.com.clock.widget.animatorview.AbstractAnimator;
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.AbstractClock;
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.DefaultPointer;
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.LeafPointer;
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.LeafTwoPointer;
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.SecondTailPointer;
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.SwordPointer;
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.TrianglePointer;
import clock.socoolby.com.clock.widget.animatorview.animator.clockanimator.pointer.TwoStepPointer;

// 参考自:https://github.com/ifadai/ClockDemo
public class ClockAnimator extends AbstractAnimator<AbstractClock> {
    private final String TAG = getClass().getSimpleName();

    AbstractClock clock;

    public ClockAnimator() {
        super(DYNAMIC_QUANTITY);
    }

    @Override
    public AbstractClock createNewEntry() {
        return null;
    }

    @Override
    public boolean run() {
        if(clock==null)
            return false;
        return super.run();
    }

    public void setClock(AbstractClock clock1){
        list.clear();
        this.clock=clock1;
        int textColor=color;
        randomColorIfAble();
        int minHigh=Math.min(width,height);
        clock.init(width,height,width/2,height/2,minHigh/2,color,textColor);
        list.add(clock);
    }

    int randPointerIndex=1;
    public void randPointer(){
        if(clock==null)
            return;
        if(randPointerIndex>6)
            randPointerIndex=0;
        switch (randPointerIndex){
            case 1:
                clock.setPointer(new SecondTailPointer());
                break;
            case 2:
                clock.setPointer(new TrianglePointer());
                break;
            case 3:
                clock.setPointer(new SwordPointer());
                break;
            case 4:
                clock.setPointer(new TwoStepPointer());
                break;
            case 5:
                clock.setPointer(new LeafPointer());
                break;
            case 6:
                clock.setPointer(new LeafTwoPointer());
                break;
            default:
                clock.setPointer(new DefaultPointer());
        }
        randPointerIndex++;
    }
}
